package com.py.credit.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.py.credit.dao.CategoryDao;
import com.py.credit.dao.ColumnDao;
import com.py.credit.entity.Category;
import com.py.credit.entity.common.TreeObj;
import com.py.credit.service.CategoryService;

@Service
public class CategoryServiceImpl implements CategoryService {

	@Autowired
	private CategoryDao categoryDao;

	@Autowired
	private ColumnDao columnDao;

	@Override
	public void add(Category category) {

		categoryDao.insert(category);

	}

	@Override
	public void update(Category category) {

		categoryDao.update(category);

	}

	@Override
	public void del(int id) {
		categoryDao.del(id);
	}

	@Override
	public boolean exist(String code) {

		return categoryDao.selectCount(code) > 0;

	}

	@Override
	public boolean existChildren(int id) {
		return categoryDao.selectChildrenCount(id) > 0;
	}

	@Override
	public List<TreeObj> getColumnNodes(String tableId) {

		return columnDao.selectColNodesFromCommonContentTable(tableId);
	}

}
